﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Common;
using TRPOP.CRM.Component.DALSQLServer;
using TRPOP.CRM.Component.Model;
namespace TRPOP.CRM.Web
{
    /// <summary>
    /// 客户历史查询
    /// </summary>
    public partial class Company_followingStoryList : BaseAdmin
    {
        #region 权限限制
        protected override void SubPageInit()
        {
            base.m_oCurrentPermissionKey = "Company_followingStoryList";
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        /// <summary>
        /// 分页触发此事件（分页采用post方法传递数据）
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UC_PagerChanged(object sender, EventArgs e)
        {
            BindData();
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strCondation = string.Empty;

            if (txtCompanyName.Text.IsEmpty() == false)
            {
                strCondation = string.Format(" AND  nvcCompanyName like '{0}' ", txtCompanyName.Text.SQLFilter());
            }

            if (txtStartTime.Text.IsEmpty() == false && txtEndTime.Text.IsEmpty() == false)
            {
                strCondation = string.Format(" AND  ( dtCreationTime Between '{0} 00:00:00' AND '{1} 23:59:59' ) ", txtStartTime.Text.Trim(), txtEndTime.Text.Trim());
            }

            ViewState["SearchCondation"] = strCondation;

            BindData();

        }
        #region 页面方法

        protected void BindData()
        {
            int RecordCount = 0;

            string strCondition = string.Empty;

            if (ViewState["SearchCondation"] != null)
            {
                strCondition = ViewState["SearchCondation"].ToString();
            }

            rptList.DataSource = CompanyManage.GetWorkingLogPager(Pager.CurrentPage, Pager.PageSize, strCondition, string.Empty, out RecordCount);

            rptList.DataBind();

            Pager.RecordCount = RecordCount;

            Pager.Page_ReLoad();
        }
        #endregion
        public static string backEmolyeeName(int id)
        {
            EmployeeDAL employdal = new EmployeeDAL();
            EmployeeInfo employee = employdal.GetInfoById(id);
            string name = employee.nvcEmployeeName;
            return name;
        }
    }
}